/**
 * X-COM PlayerController. Main PlayerController class.
 * Uses as parent class for other PlayerControllers and has public functions.
 */
class x_PlayerController extends UDKPlayerController;

//=============================================================================
// Variables: General
//=============================================================================
//var public x_GFx_MouseCursor		    MouseCursor; // MouseCursor
//var public vector                       MouseLocation, MouseDirection; //Deprojection
//var public Vector2D                     ViewportSize, ScreenCenter; // Screen size and Screen Center coordinates
//var protected x_GFx_Menu				MainMenuMovie; // Main menu.
var protected bool                      bBlockedMouseInput; //if mouse if over HUD button them world mouse click is blocked
var public x_MusicManager               MusicManager;

//=============================================================================
// Functions: For child classes
//=============================================================================

/** Shows/hides menu by pressing ESC. will be used in child classes */
//exec function ShowMainMenu();

//=============================================================================
// Functions: General
//=============================================================================
event InitInputSystem()
{
	Super.InitInputSystem();
	CharacterProcessingComplete(); //stop loading movie, which is playing while level is loading
}

simulated function PostBeginPlay()
{
	super.PostBeginPlay();
	//CreateMouseCursor();
	//GetViewportSizeAndCenter();
	if (MusicManager == None) 
	{
		MusicManager = Spawn(class'x_MusicManager', self);
		if (MusicManager != None) PlayMusic();
	}
}

/** Start to play main level music*/
function PlayMusic()
{
	MusicManager.ChangeTrack(EMST_music_Menu_MainTheme);
}

simulated event Destroyed()
{
	Super.Destroyed();

	if (MusicManager != None)
	{
		MusicManager.Destroy();
	}
	//if( MouseCursor != none )
	//{
	//	MouseCursor.Close( true );
	//	MouseCursor = none;
	//}
}

public function SetBlockMouseInput(bool bBlock)
{
	bBlockedMouseInput = bBlock;
}

//public function CreateMouseCursor()
//{
//	if ((Worldinfo.Game.class) != (class'x_GameInfo')) ///delete!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//	MouseCursor = new class'x_GFx_MouseCursor';
//	MouseCursor.Init( LocalPlayer(Player) );
//	MouseCursor.SetViewScaleMode( SM_ExactFit );
//	MouseCursor.SetAlignment( Align_Center );
//	MouseCursor.SetPriority(100);
//}

///** Used for get Screen size and Screen Center coordinates */
//function GetViewportSizeAndCenter()
//{
//	local Vector2D lViewportSize;
//	lViewportSize = MouseCursor.GetViewportSize();
//	ViewportSize = lViewportSize;
//	ScreenCenter = lViewportSize/2;
//}

///** Absolute mouse coordinates from flash movie */
//function Vector2d GetGfxMouseCoordinates()
//{
//	local Vector2d lmousePos;
	
//	lmousePos = MouseCursor.GetMouseCoords();

//	return lmousePos;
//}

///** Relative mouse coordinates from screen center */
//function Vector2d GetRelativeMouseCoordinates()
//{
//	local Vector2d lmousePos;

//	lmousePos.X = x_PlayerInput(PlayerInput).mMouseX;
//	lmousePos.Y = x_PlayerInput(PlayerInput).mMouseY;

//	return lmousePos;
//}

/** stop the loading movie that was up during precaching */
function CharacterProcessingComplete()
{
	local string LastMovie;

	LastMovie = class'Engine'.Static.GetLastMovieName();

	if(InStr(LastMovie, "UT_loadmovie") != -1)
	{
		class'Engine'.static.StopMovie(true);
	}
}

//=============================================================================
// Functions: States
//=============================================================================
/** Empty sate**/
AUTO STATE MenuState
{
}

//=============================================================================
// Default Properties
//=============================================================================
defaultproperties
{
	bKillDuringLevelTransition = TRUE
	bGodMode = TRUE

	InputClass = class'xLED_GAME.x_PlayerInput'
}
